<template>{{$t('route.Administration')}}
	<div class="customer-mgr">
		<div>
			<label>{{$t('route.Customer_Management')}}</label>
			<div></div>
			<button><img src="../../assets/img/customer-2.png" width="15" height="15"
					alt="" /><label>{{$t('route.Customer_list')}}</label></button>
		</div>

		<div>
			<input placeholder="$t('route.keyword')" />
			<button>{{$t('route.search')}}</button>
		</div>

		<div>
			<label>{{$t('route.Company_information')}}</label>
			<label>{{$t('route.contact_details')}}</label>
			<label>{{$t('route.Order_quantity')}}</label>
			<label>{{$t('route.Shipment_Report')}}</label>
			<label>{{$t('route.operate')}}</label>
		</div>

		<div>
			<div class="item" v-for="item in 20">
				<div>
					<label>{{$t('route.Sishi_Group')}}</label>
					<label>{{$t('route.Zhujing_Town_Jinshan_District_Shanghai_Jinshan_District_Shanghai')}}</label>
				</div>

				<div>
					<label>{{$t('route.full_name')}}:{{$t('route.Zhao_Ming')}}</label>
					<label>{{$t('route.telephone_book')}}：13817476510</label>
				</div>


				<div>
					<label>{{$t('route.following')}}：105</label>
				</div>

				<div>
					<button>{{$t('route.export')}}</button>
				</div>

				<div>
					<button></button>
					<button></button>
				</div>

			</div>
		</div>
		<div>
			<el-pagination style="float: right;" background layout="total, prev, pager, next" :total="1000" />
		</div>

	</div>
</template>

<script>
	import http from "../../js/http/http.js";
	import api from "../../js/http/api.js";
	import CommonUtils from "../../js/common/common-utils.js";
	import i18n from '../../i18n/index';
	export default {
		data() {
			return {
				query: {
					pageNum: 1,
					pageSize: 14
				},
				customerList: [],
				dialogVisible: false,
				customer: {},
				dialogTitle: i18n.global.t('route.Add_Customer'),
				total: 10,
			};
		},
		methods: {
			editClick(item) {
				this.customer = JSON.parse(JSON.stringify(item));
				this.dialogTitle = i18n.global.t('route.Edit_Customer');
				this.dialogVisible = true;
			},
			addClick() {
				this.customer = {};
				this.dialogTitle = i18n.global.t('route.Add_Customer');
				this.dialogVisible = true;
				console.log('======')
			},
			saveClick() {
				if (CommonUtils.isEmpty(this.customer.mobile)) {
					this.$message.error(i18n.global.t('route.phone'));
					return;
				}
				if (CommonUtils.isEmpty(this.customer.name)) {
					this.$message.error(i18n.global.t('route.Name_cannot_be_empty'));
					return;
				}
				if (CommonUtils.isEmpty(this.customer.address)) {
					this.$message.error(i18n.global.t('route.Address_cannot_be_empty'));
					return;
				}
				this.addOrUpdateCustomer();
			},
			addOrUpdateCustomer() {
				http.post(api.ADD_OR_UPDATE_CUSTOMER, {
					customerId: this.customer.id,
					mobile: this.customer.mobile,
					name: this.customer.name,
					address: this.customer.address,
				}, data => {
					this.$message.success(i18n.global.t('route.Successfully_added'));
					this.dialogVisible = false;
					this.getCustomerList();
				})
			},
			getCustomerList() {
				http.post(api.GET_CUSTOMER_LIST, {
					pageNum: this.query.pageNum,
					pageSize: this.query.pageSize
				}, data => {
					this.customerList = data.data.customerList;
					this.total = data.data.total;
				})

			},
			handlePageChange(pageNum) {
				this.query.pageNum = pageNum;
				this.getCustomerList();
			}
		},
		created() {
			this.getCustomerList();
		}
	};
</script>
<style lang="scss" scoped>
	.customer-mgr {
		color: #444444;
		font-size: 18px;

		>div:nth-of-type(1) {
			display: flex;
			flex-direction: row;
			align-items: center;
			margin-top: 20px;
			background-color: #ffffff;
			padding: 20px;
			border-radius: 5px;

			>label:nth-of-type(1) {
				font-weight: 600;
			}

			>div:nth-of-type(1) {
				width: 1px;
				background-color: #cccccc;
				height: 15px;
				margin: 0px 20px;
			}

			>button:nth-of-type(1) {
				background-image: url(../../assets/img/customer-1.png);
				background-repeat: no-repeat;
				background-size: 100% 100%;
				padding: 5px 10px;
				border: 0px;
				display: flex;
				color: #ffffff;
				flex-direction: row;
				align-items: center;
				font-weight: 800;

				>img {
					margin-right: 7px;
				}

			}

		}

		>div:nth-of-type(2) {
			display: flex;
			flex-direction: row;
			align-items: center;
			margin-top: 20px;
			background-color: #ffffff;
			padding: 10px;
			border-radius: 5px;

			>input:nth-of-type(1) {
				// border: 1px #aaaaaa;
				border: 1px solid #eeeeee;
				font-size: 15px;
				width: 150px;
				padding: 8px 15px;
				outline: none;
			}

			>button:nth-of-type(1) {
				color: #A866FF;
				border: 1px solid #A866FF;
				padding: 8px;
				border-radius: 5px;
				background-color: #ffffff;
				margin-left: 10px;
			}



		}

		>div:nth-of-type(3) {
			display: flex;
			flex-direction: row;
			align-items: center;
			margin-top: 20px;
			background-color: #ffffff;
			padding: 10px;
			border-radius: 5px;
			font-weight: 600;

			>label:nth-of-type(1),
			>label:nth-of-type(2),
			>label:nth-of-type(3),
			>label:nth-of-type(4) {
				flex: 2;
			}

			>label:nth-of-type(5) {
				flex: 1;
			}
		}

		>div:nth-of-type(4) {
			height: 550px;
			overflow: auto;


			.item {
				display: flex;
				flex-direction: row;
				align-items: center;
				margin-top: 10px;
				background-color: #ffffff;
				padding: 10px;
				border-radius: 5px;
				font-size: 15px;

				>div:nth-of-type(1),
				>div:nth-of-type(2),
				>div:nth-of-type(3),
				>div:nth-of-type(4) {
					flex: 2;
				}

				>div:nth-of-type(1) {
					display: flex;
					flex-direction: column;

					>label {
						padding: 0px 10px;
						white-space: pre-wrap;
					}

					>label:nth-of-type(2) {
						margin-top: 7px;
					}
				}

				>div:nth-of-type(2) {
					display: flex;
					flex-direction: column;

					>label {
						padding: 0px 10px;
						white-space: pre-wrap;
					}

					>label:nth-of-type(2) {
						margin-top: 7px;
					}
				}


				>div:nth-of-type(4) {

					>button:nth-of-type(1) {
						color: #A866FF;
						border: 1px solid #A866FF;
						padding: 5px 8px;
						border-radius: 5px;
						background-color: #ffffff;
						margin-left: 10px;
					}

				}




				>div:nth-of-type(5) {
					flex: 1;

					>button:nth-of-type(1) {
						border: none;
						background-image: url(../../assets/img/customer-3.png);
						background-repeat: no-repeat;
						background-size: 100% 100%;
						width: 28px;
						height: 28px;
					}

					>button:nth-of-type(2) {
						border: none;
						background-image: url(../../assets/img/customer-4.png);
						background-repeat: no-repeat;
						background-size: 100% 100%;
						margin-left: 10px;
						width: 28px;
						height: 28px;
					}

				}
			}
		}

		>div:nth-of-type(5) {
			text-align: right;
			margin-top: 10px;
		}







	}
</style>
